package com.ssy.lingxi.settle.accounts.controller;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.dto.response.PlatformAccountConfigDetailVO;
import com.ssy.lingxi.settle.accounts.model.vo.request.*;
import com.ssy.lingxi.settle.accounts.model.vo.response.*;
import com.ssy.lingxi.settle.accounts.service.IMemberSettlementStrategyService;
import com.ssy.lingxi.settle.accounts.service.IPlatformAccountConfigService;
import com.ssy.lingxi.settle.accounts.service.IPlatformInvoiceService;
import com.ssy.lingxi.settle.accounts.service.IPlatformSettlementStrategyService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 平台结算管理-平台配置
 * @author 伍将
 * @date 2020/10/20
 **/
@RestController
@RequestMapping("/settle/accounts/platform/config")
public class PlatformConfigController extends BaseController {

    @Resource
    private IPlatformAccountConfigService platformAccountConfigService;

    @Resource
    private IPlatformInvoiceService platformInvoiceService;

    @Resource
    private IMemberSettlementStrategyService strategyService;

    @Resource
    private IPlatformSettlementStrategyService platformStrategyService;

    /**
     * 平台对公账户配置-获取配置详情
     * @author 伍将
     * @date 2020/10/20
     **/
    @RequestMapping(value = "/getPlatformAccountConfig", method = RequestMethod.GET)
    public Wrapper<PlatformAccountConfigDetailVO> getPlatformAccountConfig() {
        return platformAccountConfigService.getDetail();
    }

    /**
     * 平台对公账户配置-更新配置
     * @author 伍将
     * @date 2020/10/20
     **/
    @RequestMapping("/updatePlatformAccountConfig")
    public Wrapper<Void> updatePlatformAccountConfig(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformAccountConfigUpdateVO updateVO) {
        return platformAccountConfigService.update(getSysUser(httpServletRequest), updateVO);
    }

    /**
     * 平台对公账户配置-更新配置详情
     * @author 伍将
     * @date 2020/12/17
     **/
    @RequestMapping("/updatePlatformAccountConfigDetail")
    public Wrapper<Void> updatePlatformAccountConfigDetail(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformAccountConfigUpdateItemVO updateVO) {
        return platformAccountConfigService.updateDetail(getSysUser(httpServletRequest), updateVO);
    }

    /**
     * 平台发票信息管理-获取平台发票列表
     * @author 伍将
     * @date 2020/10/20
     **/
    @RequestMapping(value = "/getPlatformInvoiceList", method = RequestMethod.GET)
    public Wrapper<List<PlatformInvoiceVO>> getPlatformInvoiceList() {
        return platformInvoiceService.getList();
    }

    /**
     * 平台发票信息管理-新增平台发票
     * @author 伍将
     * @date 2020/10/20
     **/
    @RequestMapping("/addPlatformInvoice")
    public Wrapper<Long> addPlatformInvoice(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformInvoiceAddVO addVO) {
        return platformInvoiceService.add(getSysUser(httpServletRequest), addVO);
    }

    /**
     * 平台发票信息管理-更新平台发票
     * @author 伍将
     * @date 2020/10/20
     **/
    @RequestMapping("/updatePlatformInvoice")
    public Wrapper<Void> update(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformInvoiceUpdateVO updateVO) {
        return platformInvoiceService.update(getSysUser(httpServletRequest), updateVO);
    }

    /**
     * 平台发票信息管理-删除平台发票
     * @author 伍将
     * @date 2020/10/20
     **/
    @RequestMapping("/deletePlatformInvoice")
    public Wrapper<Void> deletePlatformInvoice(HttpServletRequest httpServletRequest, @RequestBody @Valid DeletePlatformInvoiceVO deleteVo) {
        return platformInvoiceService.delete(getSysUser(httpServletRequest), deleteVo);
    }

    /***
     * 平台发票信息管理-获取平台发票详情
     * @author 伍将
     * @date 2020/10/20
     **/
    @RequestMapping(value = "/getPlatformInvoiceDetail", method = RequestMethod.GET)
    public Wrapper<PlatformInvoiceDetailVO> getPlatformInvoiceDetail(Long id) {
        return platformInvoiceService.getDetail(id);
    }

    /**
     * 会员结算策略配置-分页查询会员结算策略
     * @author 伍将
     * @date 2020/10/22
     **/
    @RequestMapping(value = "/pageMemberSettlementStrategy", method = RequestMethod.GET)
    public Wrapper<PageData<MemberSettlementStrategyVO>> pageMemberSettlementStrategy(HttpServletRequest httpRequest, @Valid MemberSettlementStrategyPageVO pageVO) {
        return strategyService.pageStrategy(getSysUser(httpRequest), pageVO);
    }

    /***
     * 会员结算策略配置-新增会员结算策略
     * @author 伍将
     * @date 2020/10/22
     **/
    @RequestMapping("/addMemberSettlementStrategy")
    public Wrapper<Long> addMemberSettlementStrategy(HttpServletRequest httpServletRequest, @RequestBody @Valid MemberSettlementStrategyAddVO addVO) {
        return strategyService.add(getSysUser(httpServletRequest), addVO);
    }

    /***
     * 会员结算策略配置-更新会员结算策略
     * @author 伍将
     * @date 2020/10/22
     **/
    @RequestMapping("/updateMemberSettlementStrategy")
    public Wrapper<Long> updateMemberSettlementStrategy(HttpServletRequest httpServletRequest, @RequestBody @Valid MemberSettlementStrategyUpdateVO updateVO) {
        return strategyService.update(getSysUser(httpServletRequest), updateVO);
    }

    /***
     * 会员结算策略配置-设置会员结算策略状态
     * @author 伍将
     * @date 2020/10/22
     **/
    @RequestMapping("/setMemberSettlementStrategyStatus")
    public Wrapper<Void> setMemberSettlementStrategyStatus(HttpServletRequest httpServletRequest, @RequestBody @Valid MemberSettlementStrategySetStatusVO setStatusVO) {
        return strategyService.setStatus(getSysUser(httpServletRequest), setStatusVO);
    }

    /**
     * 会员结算策略配置-获取会员结算策略详情
     * @author 伍将
     * @date 2020/10/22
     */
    @RequestMapping(value = "/getMemberSettlementStrategyDetail", method = RequestMethod.GET)
    public Wrapper<MemberSettlementStrategyDetailVO> getMemberSettlementStrategyDetail(Long id) {
        return strategyService.getDetail(id);
    }

    /**
     * 平台结算策略配置-分页查询平台结算策略
     * @author 伍将
     * @date 2020/11/4
     **/
    @RequestMapping(value = "/pagePlatformSettlementStrategy", method = RequestMethod.GET)
    public Wrapper<PageData<PlatformSettlementStrategyVO>> pagePlatformSettlementStrategy(HttpServletRequest httpRequest, @Valid PlatformSettlementStrategyPageVO pageVO) {
        return platformStrategyService.pageStrategy(getSysUser(httpRequest), pageVO);
    }

    /***
     * 平台结算策略配置-新增平台结算策略
     * @author 伍将
     * @date 2020/11/4
     **/
    @RequestMapping("/addPlatformSettlementStrategy")
    public Wrapper<Long> addPlatformSettlementStrategy(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformSettlementStrategyAddVO addVO) {
        return platformStrategyService.add(getSysUser(httpServletRequest), addVO);
    }

    /***
     * 平台结算策略配置-更新平台结算策略
     * @author 伍将
     * @date 2020/11/4
     **/
    @RequestMapping("/updatePlatformSettlementStrategy")
    public Wrapper<Long> updatePlatformSettlementStrategy(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformSettlementStrategyUpdateVO updateVO) {
        return platformStrategyService.update(getSysUser(httpServletRequest), updateVO);
    }

    /***
     * 平台结算策略配置-设置平台结算策略状态
     * @author 伍将
     * @date 2020/11/4
     **/
    @RequestMapping("/setPlatformSettlementStrategyStatus")
    public Wrapper<Void> setPlatformSettlementStrategyStatus(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformSettlementStrategySetStatusVO setStatusVO) {
        return platformStrategyService.setStatus(getSysUser(httpServletRequest), setStatusVO);
    }

    /**
     * 平台结算策略配置-获取平台结算策略详情
     * @author 伍将
     * @date 2020/11/4
     **/
    @RequestMapping(value = "/getPlatformSettlementStrategyDetail", method = RequestMethod.GET)
    public Wrapper<PlatformSettlementStrategyDetailVO> getPlatformSettlementStrategyDetail(Long id) {
        return platformStrategyService.getDetail(id);
    }

    /**
     * 获取结算方式
     * @author 伍将
     * @date 2020/10/22
     */
    @RequestMapping(value = "/getSettlementWay", method = RequestMethod.GET)
    public Wrapper<String> getSettlementWay(HttpServletRequest httpServletRequest, @Valid SettlementWayGetVO getVO) {
        return strategyService.getLogisticsSettlementWay(getSysUser(httpServletRequest), getVO);
    }

    /**
     * 平台结算策略配置-删除平台结算策略
     * @author 伍将
     * @date 2020/12/24
     **/
    @RequestMapping("/deletePlatformSettlementStrategy")
    public Wrapper<Void> deletePlatformSettlementStrategy(HttpServletRequest httpServletRequest, @RequestBody @Valid PlatformSettlementStrategyDeleteVO deleteVO) {
        return platformStrategyService.delete(getSysUser(httpServletRequest), deleteVO);
    }

    /**
     * 会员结算策略配置-删除会员结算策略
     * @author 伍将
     * @date 2020/12/24
     **/
    @RequestMapping("/deleteMemberSettlementStrategy")
    public Wrapper<Void> deleteMemberSettlementStrategy(HttpServletRequest httpServletRequest, @RequestBody @Valid MemberSettlementStrategyDeleteVO deleteVO) {
        return strategyService.delete(getSysUser(httpServletRequest), deleteVO);
    }
}
